<template>
    <view class="container">
        <view class="pa_1 ba_f fon_30">
            <view class="bor_bottom pa_0">
                <image class="dis_in" mode="aspectFill" src="./static/collage/stores.png"></image>
                <text class="dis_in mar_l">{{ info.store_name }}</text>
            </view>
            <view class="pa_0">
                <text class="dis_in">{{ info.goods_name }}</text>
            </view>
        </view>
        <view class="weui-cells">
            <view @tap="maketel" class="weui-cell weui-cell_access" :data-tel="info.tel">
                <view class="weui-cell__hd">
                    <image src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/lxsj.png" style="margin-right: 5px; vertical-align: middle; width: 30rpx; height: 30rpx"></image>
                </view>
                <view class="weui-cell__bd lxsj">联系商家</view>
                <view @tap.stop.prevent="location" class="weui-cell__ft weui-cell__ft_in-access lxsj">地图导航</view>
            </view>
        </view>
        <view class="pa_1 ba_f mar_t fon_30">
            <view class="bor_bottom pa_0">
                <view class="dis_in wid_50">货价</view>
                <view class="dis_in wid_50 t_r">￥{{ info.price }}</view>
            </view>
            <view class="pa_0">
                <view class="dis_in wid_50" style="color: #ed414a">合计</view>
                <view class="dis_in wid_50 t_r" :style="'color:' + color">￥{{ info.money }}</view>
            </view>
        </view>
        <view class="pa_1 ba_f fon_30 mar_t" v-if="info.state == 2 || info.status == 4">
            <view class="bor_bottom pa_0">
                <image class="dis_in" mode="aspectFill" src="./static/collage/hx_code.png"></image>
                <text class="dis_in mar_l">核销码</text>
            </view>
            <view class="pa_0 hx_code">
                <image mode="aspectFill" :src="'data:image/png;base64,' + hx_code"></image>
            </view>
        </view>
        <view class="pa_1 ba_f mar_t fon_30">
            <view class="bor_bottom pa_0">
                <image class="dis_in" mode="aspectFill" src="./static/collage/group_order.png"></image>
                <text class="dis_in mar_l">订单详情</text>
            </view>
            <view class="info fon_30">
                <view>订单号码：{{ info.order_num }}</view>
                <view v-if="info.state == 1">订单状态：未付款</view>
                <view v-if="info.state == 2">订单状态：已付款</view>
                <view v-if="info.state == 3">订单状态：已完成</view>
                <view v-if="info.state == 4">订单状态：已关闭</view>
                <view v-if="info.state == 5">订单状态：已失效</view>
                <view>下单时间：{{ info.pay_time }}</view>
                <view>消费时间：{{ info.xf_time }}</view>
                <view v-if="info.pay_type == 1">支付方式：微信支付</view>
                <view v-if="info.pay_type == 2">支付方式：余额支付</view>
            </view>
            <view class=""></view>
        </view>
        <view style="height: 120rpx"></view>
        <view class="order_title">
            <view @tap="more" class="dis_in ba_f wid_50 t_c fon_30" :style="'color:' + color">查看更多拼团商品</view>
            <view @tap="my_group" class="dis_in color_f wid_50 t_c fon_30" :style="'background:' + color" v-if="info.state == 1 || (info.state == 2 && info.status != 4)">
                查看团详情
            </view>
            <view @tap="buy" class="dis_in color_f wid_50 t_c fon_30" :style="'background:' + color" v-else>再次购买</view>
        </view>
    </view>
</template>

<script>
import cardlist from '@/ymq_canyino2o/dist/cardlist/index';
import gettel from '@/ymq_canyino2o/dist/gettel/index';
var app = getApp();
export default {
    components: {
        cardlist,
        gettel
    },
    data() {
        return {
            url: '',

            info: {
                store_name: '',
                goods_name: '',
                tel: '',
                price: '',
                money: '',
                state: 0,
                status: 0,
                order_num: '',
                pay_time: '',
                xf_time: '',
                pay_type: 0
            },

            hx_code: '',
            color: ''
        };
    },
    onLoad: function (o) {
        var that = this;
        var t = uni.getStorageSync('order_info');
        app.globalData.setNavigationBarColor(this);
        (that = this).setData({
            url: uni.getStorageSync('url')
        });
        console.log(t);
        that.setData({
            info: t
        });
        app.globalData.util.request({
            url: 'entry/wxapp/OrderCode',
            cachetime: '0',
            data: {
                order_id: t.id
            },
            success: function (o) {
                that.setData({
                    hx_code: o.data
                });
            }
        });
    },
    onReady: function () {},
    onShow: function () {},
    onHide: function () {},
    onUnload: function () {},
    onPullDownRefresh: function () {},
    onReachBottom: function () {},
    onShareAppMessage: function () {},
    methods: {
        maketel: function (o) {
            var a = o.currentTarget.dataset.tel;
            uni.makePhoneCall({
                phoneNumber: a
            });
        },

        location: function () {
            var o = this.info.coordinates.split(',');
            console.log(o);
            uni.openLocation({
                latitude: parseFloat(o[0]),
                longitude: parseFloat(o[1]),
                name: this.info.store_name
            });
        },

        my_group: function (o) {
            var a = this.info;
            uni.navigateTo({
                url: 'collageInfo?id=' + a.group_id + '&user_id=' + a.user_id + '&goods_id=' + a.goods_id
            });
        },

        buy: function (o) {
            var a = this.info;
            uni.navigateTo({
                url: '/ymq_canyino2o/pages/collage/index?id=' + a.goods_id + '&store_id=' + a.store_id
            });
        },

        more: function (o) {
            uni.navigateTo({
                url: '/ymq_canyino2o/pages/collage/group'
            });
        }
    }
};
</script>
<style>
@import './order_info.css';
</style>
